package com.hyq.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
* @ClassName: Client 
* @Description: 客户端
* @author Janus
 */
public class Client {

	public static void main(String[] args) {
		//游戏代练人员代练张三的的游戏帐号
		IGamePlayer prlayer = new Players("张三");
		//定义handler
		InvocationHandler handler=new GameLeveling(prlayer);
		//获得动态ClassLoader
		ClassLoader cl=prlayer.getClass().getClassLoader();
		//动态产生一个代理者
		IGamePlayer proxy = (IGamePlayer) Proxy.newProxyInstance(cl,new Class[]{IGamePlayer.class}, handler);
		//代练人员登录玩家游戏
		proxy.login("zhangsan");
		proxy.killBoss();
		proxy.upgrade();
		proxy.equipment();
	}

}
